define(['../../../js/lib/other/sweet-alert'],function(sweet) {
    return ['$scope', '$timeout','$location', function($scope, $timeout, $location) {
    	$scope.ldState = true;
    	proxy.checkVersion("checkVersion",
				function(ret) {
					if(ret != "" && ret != null) {
						//进入默认错误页面
						var tempData = JSON.parse(ret);
						if(tempData.retCode == '00'){//进行更新版本
							var sweetData = {
									title : "发现新版本",
									text : "是否需要更新新版本?",
									type : "",
									showCancelButton : true,
									closeOnConfirm : false
							};
			    			
			    			sweetAlert(sweetData,function(){
			    					$scope.ldState = false;
				    				var updateUrl = tempData.mobileAppVersionInfo.fileName;
									//window.location = updateUrl;
				    				var onSuccess = function(data) {
	//								    alert('extension: '          + data.extension          + '\n' +
	//								          'canBeOpen: '         + data.canBeOpen);
									};
									var onError =  function(error) {
	//								    alert('message: '    + error.message);
									}
				    				fileOpener.openFile(updateUrl,onSuccess, onError);
			    				},function(){
			    					$timeout(function(){window.location = "../home/index.html";},500);
			    				});
						}else{
							$timeout(function(){window.location = "../home/index.html";},500);
						}
					}else{
						$timeout(function(){window.location = "../home/index.html";},500);
					}
		}, function(){}, null);
    	$scope.$apply();
    }];
});
